package com.service;


import org.apache.log4j.LogManager;
import org.apache.log4j.Logger;
import org.aspectj.lang.JoinPoint;

import java.util.Arrays;

public class BaseService {

	private Logger logger = LogManager.getLogger(BaseService.class.getName());

	//指向目标方法之前进入
	public void beforeTest(JoinPoint jp){
		System.out.println("调用："+jp.getTarget()+",方法："+jp.getSignature().getName()+",参数"+
				Arrays.toString(jp.getArgs()));
		logger.info("调用："+jp.getTarget()+",方法："+jp.getSignature().getName()+",参数"+
				Arrays.toString(jp.getArgs()));
	}


	//指向目标方法之后
	public void afterTest(JoinPoint jp,Object ret){
		System.out.println("调用："+jp.getTarget()+",方法："+jp.getSignature().getName()+",参数"+
				Arrays.toString(jp.getArgs())+",方法的返回值："+ret);
		logger.info("调用："+jp.getTarget()+",方法："+jp.getSignature().getName()+",参数"+
				Arrays.toString(jp.getArgs())+",方法的返回值："+ret
		);
	}



}
